package implementor;


import model.CategoryMaster;
import dao.CategoryMasterDao;
import dbhandelling.Crude;

public class CategoryMasterImplementor extends Crude implements CategoryMasterDao
{
	String className=new CategoryMaster().getClass().getName();
	@Override
	public void add(CategoryMaster category) throws Exception 
	{
		insert(category);
	}

	@Override
	public void update(CategoryMaster category) throws Exception 
	{
		super.update(className,"status" ,category.getStatus()+"", "catCode",category.getCatCode()+"");
	}

	@Override
	public void delete(CategoryMaster category) throws Exception 
	{
		super.delete(className,"categoryNo",category.getCatCode()+"");
	}

	@Override
	public CategoryMaster retreive(String conditionField, String ConditionValue) throws Exception 
	{
		CategoryMaster category=(CategoryMaster) super.retreive(className,conditionField, ConditionValue);
		return category;
	}

	@Override
	public CategoryMaster[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		CategoryMaster[] categorys;
		Object[] obj=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		categorys=new CategoryMaster[obj.length];
		
		for(int i=0;i<categorys.length;i++)
		{
			categorys[i]=(CategoryMaster) obj[i];
		}
		
		return categorys;
	}

	@Override
	public CategoryMaster[] retreiveAll() throws Exception 
	{
		CategoryMaster[] categorys;
		
		Object[] obj=super.retreiveAll(className);
		
		categorys=new CategoryMaster[obj.length];
		
		for(int i=0;i<categorys.length;i++)
		{
			categorys[i]=(CategoryMaster) obj[i];
		}
		
		return categorys;
	}

}
